package br.com.sgi.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import br.com.sgi.dao.MembroDao;
import br.com.sgi.model.Membro;

@Repository("membroDao")
public class MembroDaoImpl extends DaoGenericoImpl<Membro> implements MembroDao {

	@Override
	@Transactional
	public List<Membro> pesquisaMembroPorFiltro(Membro filtro) {
	
		if(filtro == null)
			return new ArrayList<Membro>();
		
		Session session = (Session)getEntityManager().getDelegate();
		
		Criteria crit = session.createCriteria(Membro.class);
		
		
	    crit.add(Restrictions.like("nome", "%Marcos%"));
	    
	    return crit.list();
	}



}
